package com.ybwh.springboot2.common.jackson.mask;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


/**
 * jackson注解给字段打码,beginIndex大于字段长度无效
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@JacksonAnnotationsInside
@JsonSerialize(using = MaskFieldSerializer.class)
public @interface MaskField {


    char maskChar() default '*';

    /**
     * the beginning index, inclusive.
     *
     * @return
     */
    int beginIndex() default 0;

    /**
     * the ending index, exclusive.
     *
     * @return
     */
    int endIndex() default Integer.MAX_VALUE;

}